namespace SimpleWebServices.Web.Mvc
{
    using System;
    using System.Web.Mvc;
    using System.Web.Routing;
    using SimpleWebServices;
    using SimpleWebServices.Web.Routing;
    using Xunit;

    public sealed class ExceptionControllerFacts
    {
        [Fact]
        public void typedef()
        {
            Assert.True(new ObjectExpectations<ExceptionController>()
                .DerivesFrom<Controller>()
                .IsConcreteClass()
                .IsSealed()
                .HasDefaultConstructor()
                .Implements<IRegisterRoutes>()
                .IsDecoratedWith<InternalServerErrorAttribute>()
                .Allow("GET, HEAD, OPTIONS")
                .IsDecoratedWith<CacheControlAttribute>()
                .IsDecoratedWith<ContentLanguageAttribute>()
                .IsDecoratedWith<ContentLocationAttribute>()
                .IsDecoratedWith<ContentMD5Attribute>()
                .Result);
        }

        [Fact]
        public void ctor()
        {
            Assert.NotNull(new ExceptionController());
        }

        [Fact]
        public void op_Register_RouteCollectionNull()
        {
            Assert.Throws<ArgumentNullException>(() => (new ExceptionController() as IRegisterRoutes).Register(null));
        }

        [Fact]
        public void op_Register_RouteCollection()
        {
            RouteCollection routes = new RouteCollection();
            (new ExceptionController() as IRegisterRoutes).Register(routes);

            Assert.Equal<int>(2, routes.Count);
        }

        [Fact]
        public void op_Representation()
        {
            Assert.Throws<NotSupportedException>(() => new ExceptionController().Representation());
        }
    }
}